package com.srit.forecast.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.srit.core.bean.Page;
import com.srit.forecast.bean.City6Hours;
import com.srit.forecast.dao.City6HoursDao;

@Service
@Transactional
public class City6HoursDaoImpl implements City6HoursDao {
	@Autowired
	private JdbcTemplate jdbcTemplate;

	// ID N INTEGER Y PK
	// STATIONNUM N VARCHAR2(10) Y '58562' 站号
	// EFFECTHOURS N INTEGER Y 时效
	// MINTEMP N NUMBER Y 最低温
	// MAXTEMP N NUMBER Y 最高温
	// PREVAILINGWIND N VARCHAR2(5) Y 盛行风向
	// MAXWINDVELOCITY N VARCHAR2(5) Y 最大风力
	// PRECIPITATION N NUMBER Y 降水
	// REPORTID N INTEGER Y 预报外键
	// N Y

	@Override
	public int getMaxId() {
		String sql = "select max(id) from TI_CITY6HOURS";
		return jdbcTemplate.queryForInt(sql);
	}

	@Override
	public void save(City6Hours city6Hours) {
		String sql = "insert into TI_CITY6HOURS (ID,STATIONNUM,EFFECTHOURS,MINTEMP,MAXTEMP,PREVAILINGWIND,MAXWINDVELOCITY,PRECIPITATION,REPORTID)"
				+ " VALUES (SEQ_TI_CITY6HOURS.NEXTVAL,?,?,?,?,?,?,?,?)";
		jdbcTemplate.update(sql, new Object[] { city6Hours.getStationNum(),
				city6Hours.getEffectHours(), city6Hours.getMinTemp(),
				city6Hours.getMaxTemp(), city6Hours.getPrevailingWind(),
				city6Hours.getMaxWindVelocity(), city6Hours.getPrecipitation(),
				city6Hours.getReportId() });
	}

	@Override
	public void saveList(List<City6Hours> city6HoursList) {

	}

	@Override
	public void update(City6Hours city6Hours) {

	}

	@Override
	public City6Hours getById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void delete(Integer id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void page(Page page) {
		// TODO Auto-generated method stub
		
	}

}
